package cn.kgc.se.day03;

import java.util.Scanner;

/**
 * @author 课工场
 * @version 1.0
 * @date 2024/3/18
 * @description
 *
 * 1. 输入四位的会员卡号
 * 2. 打印输出会员卡号的每一位的数值   1234   个位数值是:4
 * 3.输出四位会员卡号每一位数值的和   1  + 2 +  3 + 4
 */
public class Demo07 {


    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入四位的会员卡号:");
        int cardNumber = scanner.nextInt();

        // 分离会员卡号  1234   ->  1  2  3  4
        int gw = cardNumber%10;  // 4
        int sw = (cardNumber/10)%10;  //  1234/10  ->123%10 ->3
        int bw = (cardNumber/100)%10; // 12 -> 12%10 -> 2
        int qw = cardNumber/1000;  //  1

        System.out.println("会员卡号的个位数是:"+gw);
        System.out.println("会员卡号的十位数是:"+sw);
        System.out.println("会员卡号的百位数是:"+bw);
        System.out.println("会员卡号的千位数是:"+qw);

        // 计算会员卡号的和
        System.out.println("会员卡号的和是:"+gw+sw+bw+qw);  // 会员卡号的和是:4321
        System.out.println("会员卡号的和是:"+(gw+sw+bw+qw));  // 10

    }

}
